package com.atguigu.gmall.product.controller.admin;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/***
 * 商标品牌表controller层接口类
 */
@RestController
@RequestMapping("/admin/product/baseTrademark")
public class BaseTrademarkController {

    @Autowired
    private BaseTrademarkService baseTrademarkService;

    /**
     * 查询所有数据
     * @return
     */
    @GetMapping("/getTrademarkList")
    public Result getTrademarkList(){
        //调用业务层方法
        List<BaseTrademark> baseTrademarkList = baseTrademarkService.list();

        //响应数据
        return Result.ok(baseTrademarkList);
    }

    /**
     * 分页查询数据
     * @param pageNum
     * @param size
     * @return
     */
    @GetMapping("/{pageNum}/{size}")
    public Result page(@PathVariable("pageNum") Long pageNum,
                       @PathVariable("size") Long size){
        //1 校验数据

        //2 调用业务层方法
        IPage<BaseTrademark> baseTrademarkIpage = baseTrademarkService.page(pageNum,size);

        //3 响应数据
        return Result.ok(baseTrademarkIpage);
    }
}
